package com.pybox.repository;

import com.pybox.entity.TCabinetUsers;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* 描述：TCabinetUsers Repository
* @author wuyingkai
* @date 2018-09-15
*/

@Repository
public interface TCabinetUsersRepository extends JpaRepository<TCabinetUsers, Integer>, JpaSpecificationExecutor<TCabinetUsers>   {

    @Query(value = "select  distinct cabinet_id  from t_cabinet_users where user_id = ?1",nativeQuery = true)
    List<Integer> findTCabinetIdByUserId(Integer userId);

    @Modifying
    @Query(value = "update t_cabinet_users set deleted =1 where cabinet_id =?1",nativeQuery = true)
    Integer updateAllCabinet(Integer cabinteId);

}